package com.xmkj.bearbiz.jifen;

import android.widget.ImageView;

import com.common.Entity.PhotoDetailEntity;
import com.common.mvp.BaseMvpActivity;
import com.common.mvp.BasePresenter;
import com.common.retrofit.method.PhotoDetailsMethods;
import com.common.retrofit.subscriber.CommonSubscriber;
import com.common.retrofit.subscriber.SubscriberListener;
import com.common.utils.EmptyUtils;
import com.common.widget.imageview.image.ImageLoaderUtils;
import com.xmkj.bearbiz.R;

public class PhotoDetailsAcitivity extends BaseMvpActivity {
    public static final String GID = "gid";
    private String gid;
    ImageView ivImg ;

    @Override
    protected BasePresenter createPresenterInstance() {
        return null;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_photo_details;
    }

    @Override
    protected void onViewCreated() {
        ivImg = findViewById(R.id.iv_img);
    }

    @Override
    protected void doLogicFunc() {
        gid = getIntent().getStringExtra(GID);
        getDatas();

    }

    private void getDatas() {
        CommonSubscriber<PhotoDetailEntity> subscriber = new CommonSubscriber<>(new SubscriberListener() {
            @Override
            public void onNext(Object o) {
                dismissProgressDialog();
                PhotoDetailEntity entity = (PhotoDetailEntity) o;
//                gotoHttpRep();
                if(EmptyUtils.isNotEmpty(entity.imgpath)){
                    ImageLoaderUtils.display(ivImg,entity.imgpath);
                }
            }

            @Override
            public void onError(String e, int code) {
                dismissProgressDialog();
                showToastMsg(e);
            }
        });
        PhotoDetailsMethods.getInstance().goodPicInfo(subscriber, uid, hashid, gid + "");
        rxManager.add(subscriber);
    }

    @Override
    protected void setNavigation() {
        setNavigationBack("图文详情");
    }
}
